package com.file.system.plugin.mybatis_plus;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

//Spring boot方式
@EnableTransactionManagement
@Configuration
public class MybatisPlusConfig {

    // 创建MybatisPlusInterceptor对象
    @Bean
    public MybatisPlusInterceptor paginationInterceptor() {

        MybatisPlusInterceptor paginationInterceptor = new MybatisPlusInterceptor();

        // 创建PaginationInnerInterceptor对象
        PaginationInnerInterceptor pi = new PaginationInnerInterceptor();
        // 设置是否超过最大值
        pi.setOverflow(true);

        // 将PaginationInnerInterceptor对象添加到MybatisPlusInterceptor对象中
        paginationInterceptor.addInnerInterceptor(pi);
        // 返回MybatisPlusInterceptor对象
        return paginationInterceptor;
    }
}